package com.woniu.service.impl;

import com.woniu.entity.CommunityOrder;
import com.woniu.dao.CommunityOrderDao;
import com.woniu.service.CommunityOrderService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (CommunityOrder)表服务实现类
 *
 * @author makejava
 * @since 2020-03-26 18:24:40
 */
@Service("communityOrderService")
public class CommunityOrderServiceImpl implements CommunityOrderService {
    @Resource
    private CommunityOrderDao communityOrderDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public CommunityOrder queryById(Integer id) {
        return this.communityOrderDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<CommunityOrder> queryAllByLimit(int offset, int limit) {
        return this.communityOrderDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param communityOrder 实例对象
     * @return 实例对象
     */
    @Override
    public CommunityOrder insert(CommunityOrder communityOrder) {
        this.communityOrderDao.insert(communityOrder);
        return communityOrder;
    }

    /**
     * 修改数据
     *
     * @param communityOrder 实例对象
     * @return 实例对象
     */
    @Override
    public CommunityOrder update(CommunityOrder communityOrder) {
        this.communityOrderDao.update(communityOrder);
        return this.queryById(communityOrder.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.communityOrderDao.deleteById(id) > 0;
    }
}